#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <dirent.h>
#include <string.h>
#include <time.h>

void showfilelist(const char *f)
{
	DIR *dir = opendir(f);
	struct dirent *a;
	struct stat buf;
	char f2[100];
	while (a = readdir(dir))
	{
		if(strcmp(a->d_name,".") == 0 || strcmp(a->d_name,"..") == 0 )
			continue;
		
		stat(a->d_name,&buf);
		printf("%s  ",a->d_name);
		printf("%d  ",buf.st_size);
		printf("%s",ctime(&buf.st_mtime));
//		printf("%d\n",S_ISDIR(buf.st_mode));

		if( S_ISDIR(buf.st_mode) == 1 )
		{	
			memset(f2,'\0',sizeof(f2));	
			strcpy(f2,f);	
			strcat(f2,"/");
			strcat(f2,a->d_name);
			showfilelist(f2);
		}			
	}
	closedir(dir);
	return ;
}

void main()
{
	showfilelist("/home/diwutiantang/snap/lc/Jan/0108");
}